<?php
/*==========================================================================*\
| AGRIVIET - CONTENT MANAGERMENT SYSTEM						
\*==========================================================================*/


	//Xoa nhieu fan tu cung 1 luc
	if (isset($_POST['ButDel'])) {

		$cnt=0;
		foreach ($_POST['chk'] as $id)
		{			
			$pro=getCat($id,'cv');
			
			if ($pro)
			{
				$result = mysql_query("delete from cv where id='".$id."'");
				//$result.= mysql_query("delete from news_categories_des where id='".$id."'");
				if ($result) {
					$cnt++;		
				}
			}
		}
		
		/*$sql=mysql_query("SELECT * FROM languages order by ordering ASC");
		while($r=mysql_fetch_object($sql)){
		
		$SQL="select * from categories WHERE ";
		$SQL .=" published=1 and parent_id=0 order by ordering ASC";
					
		echo create_categories($SQL,$r->languages_id,"../modules/html/categories_".$r->code.".html","./category");
		}*/
			// Top MenE NEWS
	$sql = 'SELECT * FROM cv WHERE  order by ordering ASC';
	$query = mysql_query($sql);
	while ( $row = mysql_fetch_object($query) )
	{
	   $menu_array[$row->id] = array('id' => $row->id,
									 'name' => $row->title,
									 'alias' => $row->alias,
									'section' => $row->section,
									 'links' => $row->links,
									 'parent' => $row->parent_id
									 );
	}
	//$tpl->assign('topmenu',generate_menu(0));
	echo create_topmenu(generate_menu(0,'news'),'../html/newsmenu.htm');
		echo "<script>window.location='./?act=cv'</script>";
		#echo "<div align=center class='blue'>Đã xóa ".$cnt." phần tử</div>";
		
	}
		
	
		
 if($_GET['code']==1) echo '<div class="blue">Đã cập nhật thành công</div>'; ?>
 
<form method="POST" name="frmList" action="index.php">
 <input type="hidden" name="act" value="cv">

<table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#D5E2FF" width="100%" id="AutoNumber1">

  <tr>
    <td height="24" colspan="7" align=left class="xtitle">CÁC CÔNG VIÊN ĐANG QUẢN LÝ </td>
    </tr>
  <tr>

    <td align=center class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
    <td align=left class="title" >Tên</td>

    <td align="left" nowrap class="title">Đơn vị quản lý </td>
    <td align="center" nowrap class="title">Địa Bàn </td>
	<td align="center" nowrap class="title">Giám sát PKT</td>
   
    <td align="center" nowrap class="title">Ordering</td>
    
    </tr>
<?php
	$sql="select cv.*,bql.title as bql_title  from cv cv LEFT JOIN cv_bql bql ON(cv.catid=bql.id) order by cv.title ASC";
	
	$result=@mysql_query($sql);
	$total_records=@mysql_num_rows($result);
	$record_per_page=10;
	$scroll=5;
	$row->published=1;

	$page=new Page(); ///creating new instance of Class Page
	$page->set_page_data($urllink,$total_records,$record_per_page,$scroll,true,true,true);
	$page->set_qry_string();
	
	if($result=mysql_query($page->get_limit_query($sql))){
	
	$i=0;
	while($row=mysql_fetch_object($result)){

	$i++;
	if ($i%2) $class="le"; else $class="chan";
?>
  <tr class="<?=$class;?>">
    <td align="center">
    <input type="checkbox" name="chk[]" value="<? echo $row->id; ?>"></td>
    <td align="left" >
	<a href="index.php?act=<?=$_GET['act'];?>_m&id=<? echo $row->id; ?>&page=<?=$_GET['page'];?>">
	<b><? echo $row->title; ?></b></a></td>

    <td align="left" style="overflow: hidden"><? echo $row->bql_title; ?></td>
    <td align="center" > KHU QLGTĐT SỐ <? echo $row->khu; ?> </td>
    <td align="center" >Coding...</td>
    <td align="center" ><? echo $row->ordering; ?></td>
    
    </tr>

<?
	}
}
?>
</table>


<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
	<tr>
		<td width="50%">

<input type="submit" value="Delete" name="ButDel" onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" class="button">
<input name="new" type="button" id="new" value="Add new" onclick="window.location='index.php?act=<?=$_GET['act'];?>_m'" class="button" /></td>
        <td width="50%" align="right"><div id="pagenav"><?=$page->get_page_nav();?></div></td>
	</tr>
	<tr>
	  <td colspan="2">&nbsp;</td>
    </tr>
</table>
</form>